//
//  RBGoodsEvaluateListCell.m
//  zhongzhenglu
//
//  Created by 马军凯 on 2023/5/9.
//

#import "RBGoodsEvaluateListCell.h"

@interface RBGoodsEvaluateListCell ()
//头像
@property (weak, nonatomic) IBOutlet UIImageView *avatarImageView;
//昵称
@property (weak, nonatomic) IBOutlet UILabel *nicknameLabel;
//时间
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
//星星宽度
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *starWidth;
//内容
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;
//图片背景
@property (weak, nonatomic) IBOutlet UIView *photoBackView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *photoHeight;


@end

@implementation RBGoodsEvaluateListCell

- (void)awakeFromNib {
    [super awakeFromNib];
}
//赋值
- (void)setModel:(RBGoodsEvaluateDataModel *)model {
    _model = model;
    //头像
    [self.avatarImageView setImageWithUrl:model.avatar placeHolder:nil];
    //昵称
    self.nicknameLabel.text = model.nickname;
    //时间
    self.timeLabel.text = model.create_time;
    //星星
    NSInteger star = [model.star_num integerValue];
    self.starWidth.constant = 12 * star + 5 * (star - 1);
    //评价内容
    self.contentLabel.text = model.content;
    //图片
    [self.photoBackView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.photoHeight.constant = 0;
    if (model.multiple_file.count > 0) {
        CGFloat itemX = 0;
        CGFloat itemY = 0;
        CGFloat itemW = 70;
        CGFloat itemH = 70;
        for (NSString *file in model.multiple_file) {
            if ((itemX + itemW) > (SCREEN_WIDTH - 40)) {
                itemX = 0;
                itemY = itemY + itemH + 15;
            }
            UIImageView *fileImageView = UIImageView.new;
            fileImageView.contentMode = UIViewContentModeScaleToFill;
            [fileImageView rbSetCornerRadius:5];
            [fileImageView setImageWithUrl:file placeHolder:nil];
            fileImageView.frame = CGRectMake(itemX, itemY, itemW, itemH);
            [self.photoBackView addSubview:fileImageView];
            
            itemX = itemX + itemW + 10;
        }
        self.photoHeight.constant = itemY + itemH + 15;
    }
}




- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
